{extend  name="manage@public/layout" /}
{block name="content"}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                      
                        <h5 style="margin:-5px 5px 0px !important;">
                            <button onClick="modaldemo()" style="padding:4px;margin-bottom:0 !important" type="button" class="btn btn-primary btn-xs">申请提现</button>
                        </h5>
                      
                        <div class="ibox-tools">
                            <a class="collapse-link" onclick="location.replace(location.href);">
                                <i class="fa fa-refresh"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <!--- 搜索--->
                            <form action="" method="post">
                                <div class="col-sm-2 col-sm-on">
                                    <select name="status" class="input-sm form-control input-s-sm inline">
                                        <option selected value="0">出款状态</option>
                                        <option {notempty name="data['status']"}{eq name="data['status']" value="1"}selected{/eq}{/notempty} value="1">处理中</option>
                                        <option {notempty name="data['status']"}{eq name="data['status']" value="3"}selected{/eq}{/notempty} value="3">成功,已打款</option>
                                        <option {notempty name="data['status']"}{eq name="data['status']" value="4"}selected{/eq}{/notempty} value="4">失败,已退款</option>
                                    </select>
                                </div>
                                <div class="col-sm-2 col-sm-on">
                                    <input type="text" value="{notempty name="data['keyword']"}{$data['keyword']}{/notempty}" name="keyword" placeholder="系统单号" class="input-sm form-control">
                                </div>
                                <div class="col-sm-auto col-sm-4 col-sm-on">
                                    <input style="width:155px;cursor:not-allowed;" placeholder="开始日期" class="input-sm form-control form-control layer-date" name="start" value="{empty name="data['start']"}<?php echo date('Y-m-d 00:00:00',time());?>{else/}{$data.start}{/empty}" readonly id="start"><i style="position: relative;top:5px;">&nbsp;-&nbsp;</i>
                                    <input style="width:155px;cursor:not-allowed;" placeholder="结束日期" class="input-sm form-control form-control layer-date" name="end" value="{empty name="data['end']"}<?php echo date('Y-m-d H:i:s',time());?>{else/}{$data.end}{/empty}" readonly id="end">
                                </div>
                                <div class="col-sm-1 col-sm-botton">
                                    <div class="input-group">
                                        <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i></button>
                                    </div>
                                </div>
                            </form>
                            <!--- end --->
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>订单号</th>
                                       
                                        <th>手续费</th>
                                        <th>申请金额</th>
                                        <th>实际到账</th>
                                        <th>开户人</th>
                                        <th>银行卡号</th>
                                        <th>所属银行</th>
                                        <!-- <th>所在支行</th> 
                                        <th>开卡城市</th>-->
                                        <th>状态</th>
                                        <th>申请时间</th>
                                        <th>备注</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="list" id="vo"}
                                    <tr>
                                        <td>{$vo.id}</td>
                                        <td>{$vo.with_out_no}</td>
                                        <td>{$vo.poundage|abs}</td>
                                        <td>{$vo.total_fee|abs}</td>
                                        <td style="color: red;">{$vo.actual_fee|abs}</td>
                                        <td>{$vo.account_name}</td>
                                        <td>{$vo.card_number}</td>
                                        <td>{$vo.bank_name}</td>
                                        <!-- <td>{$vo.branch}</td> 
                                        <td>{$vo.location}</td>-->
                                        <td>
                                            {switch vo.status }
                                            {case 1|2 }<small style="color: #1c84c6;">处理中</small>{/case}
                                            {case 3}<small style="color:#23b313;">已打款</small>{/case}
                                            {default /}<small style="color:red;">失败,已退款</small>
                                            {/switch}
                                        </td>
                                        <td>{$vo.create_time}</td>
                                        <td>{$vo.remark}</td>
                                        <td>
                                            <span class="btn btn-sm btn-white"> <i class="fa fa-ban">&nbsp;暂无操作</i> </span>
                                        </td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                            <div style="float:right;" class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {$page|raw}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div> 
     <!-- 弹框 --->
     <div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content radius">
                <div class="modal-header">
                    <h3 class="modal-title">提现申请</h3>
                    <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
                </div>
                
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">可用余额</label>
                        <div class="col-sm-7">
                            <input type="text" data-am="{$info->balance|abs}" disabled placeholder="可用余额：{$info->balance|abs}元 冻结：{$info->freeze|abs}元" name="total_t" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">银行卡</label>
                        <div class="col-sm-7">
                                <select id="bank_id" class="form-control m-b" name="agent">
                                    <option value="0">请选择银行卡</option>
                                    {volist name="bank" id="vo"}
                                    <option value="{$vo.id}">{$vo.card_number|substr_replace='*******',6,8}[{$vo.bank_name}]</option>
                                    {/volist}
                                </select>
                        </div>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">申请金额</label>
                        <div class="col-sm-7">
                            <input type="text" onkeyup="value=value.replace(/[^\d.]/g,'')" placeholder="请输入申请金额" name="total_fee" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">谷歌验证码</label>
                        <div class="col-sm-7">
                            <input type="text" placeholder="请输入谷歌验证码" name="google_code" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary bt-apply">确定</button>
                    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <!--  end --->
    <input type='hidden' name="st_start" value="<?php echo date('Y-m-d 00:00:00',strtotime('-7 days'))?>" />
    <input type='hidden' name="st_end" value="<?php echo date('Y-m-d 23:59:59',time());?>" />
{/block}
{block name="script"}
<script>
   function modaldemo(){
        $("#modal-demo").modal("show");
    }
    function turn_down(id) {
        $("#wid").val(id);
        $("#modal-demo-no").modal("show");
    }

//提现申请
$(".bt-apply").click(function(){
    
   
    var bank_id = $("#bank_id option:selected").val();
    var total_fee = $("input[name='total_fee']").val();
    var google_code = $("input[name='google_code']").val();
    if(bank_id == '0'){
        parent.layer.msg('至少选择一张银行卡');
        return false;
    }
    total_t = $("input[name='total_t']").attr("data-am");
    if(total_fee == ''){
        parent.layer.msg('金额不能为空');
        return false;
    }
    if(parseFloat(total_fee) >= parseFloat(total_t)){
        parent.layer.msg('余额不足');
        return false;
    }
    if(google_code == '0'){
        parent.layer.msg('谷歌验证码不能为空');
        return false;
    }
    //设置不可点击，避免重复提交
    $(".bt-apply").attr({ disabled: "disabled" });
    index = parent.layer.load(0, {shade: false});//添加加载动画
    $.post('/web/withRequest',{bank_id:bank_id,google_code:google_code,total_fee:total_fee},function(result){
        parent.layer.msg(result.msg);
        parent.layer.close(index);
        if(result.code == '1'){
            setTimeout(function() {
                window.location.reload();
            }, 1000)
        }else{
            $(".bt-apply").removeAttr("disabled");
        }
    });
})
//时间插件
var start = {
        elem:"#start",
        format:"YYYY-MM-DD hh:mm:ss",
        min:$("input[name='st_start']").val(),
        max:$("input[name='st_end']").val(),
        istime:true,
    };
    var end = {
        elem:"#end",
        format:"YYYY-MM-DD hh:mm:ss",
        min:$("input[name='st_start']").val(),
        max:$("input[name='st_end']").val(),
        istime:true,
    };
    laydate(start);laydate(end);
</script>
{/block}

